import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import Class from "../views/Class.vue";
import New from "../views/template-views.vue";
import About from "../views/About.vue";
import Detail from "../views/Detail.vue";
import HelloWorld from "../components/HelloWorld.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "HelloWorld",
    component: HelloWorld,
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
    children: [
      {
        path: "/home",
        name: "Home",
        component: New,
      },
      {
        path: "/class",
        name: "Class",
        component: Class,
      },
      {
        path: "/about",
        name: "About",
        component: About,
      },
      {
        path: "/detail/:id",
        name: "Detail",
        props: true,
        component: Detail,
      },
      {
        path: "/about",
        name: "About",
        component: About,
      },
      {
        path: "/detail/:id",
        name: "Detail",
        props: true,
        component: Detail,
      },
    ],
  },
];

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const router = new VueRouter({
  routes,
});

export default router;
